package com.shanzmoo.platform.manage.api.web.product;

import com.shanzmoo.base.bean.SHttpResponse;
import com.shanzmoo.db.module.product.domain.dto.CategorySaveDto;
import com.shanzmoo.db.module.product.domain.dto.CategoryUpdateDto;
import com.shanzmoo.db.module.product.domain.vo.CategoryVO;
import com.shanzmoo.platform.manage.api.manager.product.ProductCategoryManager;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 商品分类manager
 * @author xueqz
 */
@Api(tags = "商品管理系统-分类")
@RestController
@RequestMapping("/api/product/category")
public class ProductCategoryController {

    @Autowired
    private ProductCategoryManager productCategoryManager;

    @ApiOperation(value = "分类列表树")
    @GetMapping("/getCategoryTree")
    public SHttpResponse<List<CategoryVO>> getCategoryTree() {

        return productCategoryManager.getCategoryTree();
    }

    @ApiOperation(value = "删除商品品牌")
    @GetMapping("/delCatById")
    public SHttpResponse<Boolean> delCatById(@RequestParam(value = "catId") Integer catId) {

        return productCategoryManager.delCatById(catId);
    }

    @ApiOperation(value = "添加商品分类")
    @PostMapping("/addCat")
    public SHttpResponse<Boolean> addCat(@RequestBody CategorySaveDto categorySaveDto) {


        return productCategoryManager.addCat(categorySaveDto);
    }


    @ApiOperation(value = "编辑商品分类")
    @PostMapping("/editCat")
    public SHttpResponse<Boolean> editCat(@RequestBody CategoryUpdateDto categoryUpdateDto) {

        return productCategoryManager.editCat(categoryUpdateDto);
    }


}
